package pass

import (
	"errors"
	"strings"
)

type PasswordEncoder interface {
	Encode(rawpass string) (string, error)
	Matches(rawpass string, encpass string) bool
}

type NonePasswordEncoder struct {
}

func (n *NonePasswordEncoder) Encode(rawpass string) (string, error) {
	return rawpass, nil
}

func (n *NonePasswordEncoder) Matches(rawpass string, encpass string) bool {
	return strings.Compare(rawpass, encpass) == 0
}

func NewNonePasswordEncoder() PasswordEncoder {
	return &NonePasswordEncoder{}
}

var SaltFailed = errors.New("create salt failed")

var ParseFailed = errors.New("parse encode hash failed")
